package com.dense.kuiniu.shelfcard;

import android.app.Application;

import com.blankj.utilcode.util.SPUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.blankj.utilcode.util.Utils;
import com.dense.kuiniu.shelfcard.base.SpKey;
import com.dense.kuiniu.shelfcard.base.Url;

import java.util.concurrent.TimeUnit;


import okhttp3.OkHttpClient;
import rxhttp.RxHttp;

/**
 * @author Administrator
 * @date 2020/8/6
 */
public class App extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        Utils.init(this);
        ToastUtils.setBgResource(R.drawable.shape_bg_toast);
        RxHttp.init(new OkHttpClient.Builder()
                .connectTimeout(5, TimeUnit.SECONDS)
                .readTimeout(5, TimeUnit.SECONDS)
                .writeTimeout(5, TimeUnit.SECONDS)
                .hostnameVerifier((hostname, session) -> true) //忽略host验证
                .build(), true);
        String baseUrl = SPUtils.getInstance().getString(SpKey.KEY_BASE_URL);
        if (!baseUrl.isEmpty()) {
            Url.baseUrl = baseUrl;
        }
    }

}